<!--  -->
<template>
  <div class="categorylist">
    <el-col :span="24">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>商品管理</el-breadcrumb-item>
        <el-breadcrumb-item>分类列表</el-breadcrumb-item>
      </el-breadcrumb>
    </el-col>
    <el-card>
      <el-table
        :data="tableData.data"
        style="width: 100%; margin-bottom: 20px"
        row-key="cate_id"
        border
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
      >
        <el-table-column prop="cate_id" label="ID" sortable width="180">
        </el-table-column>
        <el-table-column prop="cate_name" label="分类名称" sortable width="180">
        </el-table-column>
        <el-table-column prop="cate_price" label="价格"> </el-table-column>
        <el-table-column fixed="right" label="操作" width="150">
          <template slot-scope="scope">
            <el-button type="primary" size="small">编辑</el-button>
            <el-button type="danger" size="small" @click="deleUserFn(scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
       <el-pagination
        background
        layout="total,prev, pager, next,jumper"
        :page-size="1"
        :total="tableData.total"
        @current-change="changePage"
      ></el-pagination>
    </el-card>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到components对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      page: 1,
      size: 5,
    };
  },
  computed: {
    tableData() {
      return this.$store.state.categoryDatas;
    },
  },
  methods: {
    getcategorylist() {
      this.$store.dispatch("actchangecategoryDatas", {
        page: this.page,
        size: this.size,
      });
    },
    deleUserFn(rowData){
        console.log(rowData);
    },
    changePage(page){
        this.page=page;
        this.getcategorylist();
    }
  },
  mounted() {
    this.getcategorylist();
    // console.log(this.tableData);
  },
};
</script>
<style>
</style>